package com.example.scenictourback.dto;

import com.example.scenictourback.entity.Ticket;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;

@Data
public class TicketDTO {
    
    private Integer id;
    private Integer scenicAreaId;
    private String scenicAreaName;
    private String name;
    private BigDecimal price;
    private Integer validDays;
    private Integer totalQuantity;
    private Integer availableQuantity;
    private String description;
    
    // 静态方法，将实体对象转为DTO对象
    public static TicketDTO fromEntity(Ticket ticket) {
        TicketDTO dto = new TicketDTO();
        dto.setId(ticket.getId());
        dto.setScenicAreaId(ticket.getScenicArea().getId());
        dto.setScenicAreaName(ticket.getScenicArea().getName());
        dto.setName(ticket.getName());
        dto.setPrice(ticket.getPrice());
        dto.setValidDays(ticket.getValidDays());
        dto.setTotalQuantity(ticket.getTotalQuantity());
        dto.setAvailableQuantity(ticket.getAvailableQuantity());
        dto.setDescription(ticket.getDescription());
        return dto;
    }
    
    // 静态方法，将实体列表转为DTO列表
    public static List<TicketDTO> fromEntities(List<Ticket> tickets) {
        return tickets.stream()
                .map(TicketDTO::fromEntity)
                .collect(Collectors.toList());
    }
} 